import { Component, OnInit } from '@angular/core';
import {Avatar} from '../entity/Avatar';

import {EventService, EventSource} from '../services/event.service';
import { RequestReplyService } from '../services/request-reply.service';
import { UserType } from '../entity/TT';

@Component({
  selector: 'app-navigater',
  templateUrl: './navigater.component.html',
  styleUrls: ['./navigater.component.scss']
})
export class NavigaterComponent implements OnInit {

  toggledChat = false;

  constructor(private eventService: EventService,
              private requestService: RequestReplyService) { }

  ngOnInit() {
  }

  toggleChat() {
    this.toggledChat = ! this.toggledChat;
    this.eventService.sendToggle(EventSource.CHAT, this.toggledChat);
  }

  getAvatar() {
    return this.requestService.avatar;
  }

  getPersonalUrl() {
    let url: string;
    const me = this.requestService.LoadMe();
    if (me) {
      switch (me.userType) {
        case UserType.Member:
          url = '//mc.olcedu.cn';
          break;
        case UserType.Teacher:
            url = '//tc.olcedu.cn';
            break;
      }
    }
    return url;
  }

  getMailUrl() {
    let url: string;
    const me = this.requestService.LoadMe();
    if (me) {
      switch (me.userType) {
        case UserType.Member:
          url = '//mc.olcedu.cn/ua/go/mail.do';
          break;
        case UserType.Teacher:
          url = '//tc.olcedu.cn/ua/go/mail.do';
          break;
      }
    }
    return url;
  }

  toggleRecord(){
    alert('演示版不支持！')
  }

  toggleSchedule(){
    alert('演示版不支持！')
  }

  toggleEMail(){
    alert('演示版不支持！')
  }

  togglePersonal(){
    alert('演示版不支持！')
  }

}
